package com.skeyedu.book.utils;


import net.minidev.json.JSONObject;

public class Result  extends JSONObject{

    public static final String SUCCESS = "success";
    public static final String FAILURE = "error";

    private boolean result;
    private String msg;
    private Object data;

    private Result() {}

    public static Result ok() {
        return Result.ok(SUCCESS);
    }

    public static Result ok(String msg) {
        return Result.ok(msg, null);
    }


    public static Result ok(String dataName, Object data) {
        Result result = new Result();
        result.put("msg:",SUCCESS);
        result.put(dataName,data);
        return result;
    }

    public static Result fail() {
        return Result.fail(FAILURE);
    }

    public static Result fail(String msg) {
        return Result.fail(msg, null);
    }


    public static Result fail(String dataName, Object data) {
        Result result = new Result();
        result.put("msg:",FAILURE);
        result.put(dataName,data);
        return result;
    }

    public boolean isResult() {
        return result;
    }
    public void setResult(boolean result) {
        this.result = result;
    }
    public String getMsg() {
        return msg;
    }
    public void setMsg(String msg) {
        this.msg = msg;
    }
    public Object getData() {
        return data;
    }
    public void setData(Object data) {
        this.data = data;
    }
}
